import type { RouteRecordRaw } from 'vue-router'
import { Layout } from '../constant'
import IconMenuSetting from '~icons/local/menu-setting-color'

// 机构设置
const orgination: RouteRecordRaw = {
  path: 'orgination',
  name: 'Orgination',
  meta: {
    title: '机构管理',
    group: true,
  },
  children: [
    {
      path: 'org',
      name: 'Org',
      component: () => import('@/views/system/org/index.vue'),
      meta: {
        title: '校区与部门',
        code: 'system:org:manage',
        icon: 'icon-mind-mapping',
      },
    },
    {
      path: 'employee/list',
      name: 'EmployeeIndex',
      component: () => import('@/views/system/employee/index.vue'),
      meta: {
        title: '员工管理',
        code: 'system:org:manage',
        icon: 'icon-user',
      },
    },
    {
      path: 'permission',
      name: 'Permission',
      component: () => import('@/views/system/permission/index.vue'),
      meta: {
        title: '权限管理',
        code: 'system:org:manage',
        icon: 'icon-relation',
      },
    },
    {
      path: 'classroom',
      name: 'Classroom',
      component: () => import('@/views/system/classroom/index.vue'),
      meta: {
        title: '教室管理',
        code: 'system:org:manage',
        icon: 'icon-list',
      },
    },
  ],
}

// 业务设置
const business: RouteRecordRaw = {
  path: 'business',
  name: 'business',
  meta: {
    title: '业务设置',
    group: true,
  },
  children: [
    {
      path: 'info',
      name: 'BaseInfo',
      component: () => import('@/views/system/business/info/index.vue'),
      meta: {
        title: '基础信息',
        code: 'system:biz-info:manage',
        icon: 'icon-bookmark',
      },
    },
    {
      path: 'rules',
      name: 'BusinessRules',
      component: () => import('@/views/system/business/rules/index.vue'),
      meta: {
        title: '业务规则',
        code: 'system:biz-rule:manage',
        icon: 'icon-bookmark',
      },
    },
    {
      path: 'account',
      name: 'Account',
      component: () => import('@/views/financial/account/index.vue'),
      meta: {
        title: '财务账户',
        code: 'system:fin-account:manage',
        icon: 'icon-dashboard',
      },
    },
  ],
}

// 系统设置
const config: RouteRecordRaw = {
  path: 'config',
  name: 'config',
  meta: {
    title: '系统设置',
    group: true,
  },
  children: [
    {
      path: 'index',
      name: 'SystemConfig',
      component: () => import('@/views/system/config/index.vue'),
      meta: {
        title: '系统配置',
        code: 'system:biz-config:manage',
        icon: 'icon-settings',
      },
    },
  ],
}

export default <RouteRecordRaw> {
  path: '/system',
  name: 'System',
  component: Layout,
  meta: {
    title: '管理中心',
    icon: shallowRef(IconMenuSetting),
    sort: 10,
  },
  children: [
    orgination,
    business,
    config,
  ],
}
